package com.am.util;

import org.springframework.util.DigestUtils;

import java.util.Date;

public class MD5Code {
    public static String strToMD5(String str) {
        byte[] bts = str.getBytes();
        String md5 = DigestUtils.md5DigestAsHex(bts);
        return md5.toString();
    }

    public static String getMD5FromTsp() {
        Long date = new Date().getTime();
        String str = String.valueOf(date);
        return strToMD5(str);
    }

    public static String getMD5FromTsp16() {
        return getMD5FromTsp().substring(8, 24);
    }

    public static void main(String[] args) {
        System.out.println(getMD5FromTsp16());
    }
}
